<template>
	<view class="shipped">
		<view v-for="(item,index) in props.item.storeDTOS" :key="index">
			<view class="topItem">
				<view class="left">
					<image :src="data.httpUrl+'/app/file/viewFile?fileId='+item.storeLogo" mode="aspectFill"></image>
					{{item.storeName}}
				</view>
				<view class="right">
					待收货
				</view>
			</view>
		
			<Item v-for="(item1,index1) in item.productDTOS" :key="index1" :item="item1" />
			<view class="logistics" v-for="(item1,index1) in item.emsInfoDTOS.slice(0,1)" :key="index1">
				<view class="left">
					<view class="">
						<image src="/static/img/index/132.png" mode="widthFix"></image>
						{{item1.logisticsStatusDesc}}
					</view>
					<text class="ellipsis_1">{{item1.theLastMessage}}</text>
					
				</view>
				<image src="/static/img/index/58.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="bot1">
			下单时间:{{item.createTime}}
			<view class="">
				实付款
				<text>￥{{props.item.totalPayAmount}}</text>
			</view>
		</view>
		<view class="bot">
			<text @tap.stop="handeSh(item)">确认收货</text>
			<text @tap.stop="handeClick(item)">查看物流信息</text>
		</view>
	</view>
</template>

<script setup lang="ts">
	//待收货
	import Item from './item'
	import { reactive } from 'vue';
	import {receiveOrder} from '@/utils/api/goods'
	const props = defineProps(['item','orderState'])
	const emit = defineEmits(['handeDelete'])
	const data = reactive<any>({
		httpUrl: getApp().globalData.baseUrl,
	})
	const handeClick=(item)=>{
		uni.navigateTo({
			url:'/pages/logistics/index?id='+item.groupOrderNo
		})
	}
	const handeSh=(item)=>{
		uni.showModal({
			title:'提示',
			content:'是否收货?',
			success:(e)=>{
				if(e.confirm){
					receiveOrder({data:{groupOrderNo:item.groupOrderNo}}).then((res)=>{
						console.log(res,'ress')
						if(res.code == 200){
							uni.showToast({
								title: '收货成功!',
								icon: 'none'
							})
							if(props.orderState){
								emit('handeDelete')
							}else{
								item.orderState.value = 'COMPLETE'
							}
						}
					})
				}
			}
		})
	}
</script>

<style lang="scss">
	.shipped {
		.logistics{
			padding: 16rpx;
			border-radius: 16rpx;
			background: #F4F6FA;
			display: flex;
			align-items: center;
			margin-top: 24rpx;
			>image{
				width: 40rpx;
			}
			.left{
				flex: 1;
				margin-right: 20rpx;
				display: flex;
				flex-direction: column;
			
				width: 0;
				image{
					width: 48rpx;
					margin-right: 10rpx;
				}
				view{
					margin-bottom: 10rpx;
					display: flex;
					align-items: center;
					
				}
				text{
					font-size: 24rpx;
					color: #595959;
					width: 100%;
				}
			}
		}
		>.bot1 {
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 24rpx;
			color: #8C8C8C;
			margin-top: 25rpx;

			view {
				font-size: 24rpx;

				text {
					font-size: 36rpx;
					color: #6B64D3;
				}
			}
		}

		>.bot {
			margin-top: 33rpx;
			display: flex;
			align-items: flex-end;
			justify-content: flex-end;

			text {
				padding: 11rpx 24rpx;
				border-radius: 100rpx;
			}

			text:nth-of-type(1) {
				border: 2rpx solid #D9D9D9;
				margin-right: 16rpx;
			}

			text:nth-of-type(2) {
				color: #6B64D3;
				border: 2rpx solid #6B64D3;
			}
		}

		.topItem {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;
				font-size: 32rpx;

				image {
					width: 48rpx;
					height: 48rpx;
					border-radius: 50%;
					margin-right: 16rpx;
				}
			}

			.right {
				color: #FF8C00;
			}
		}
	}
</style>